<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="tab.css">
</head>
<body>
<div class="tab--container">
    <ul class="tab--toggleBar">
        <li class="tab--toggleBar__item tab--toggleBar__item__active">tab-1</li>
        <li class="tab--toggleBar__item">tab-2</li>
        <li class="tab--toggleBar__item">tab-3</li>
    </ul>
    <ul class="tab--content">
        <li class="tab--content__item tab--content__item__show">content-1</li>
        <li class="tab--content__item">content-2</li>
        <li class="tab--content__item">content-3</li>
    </ul>
</div>
</body>
<script>
    var toggleBarList = document.getElementsByClassName("tab--toggleBar__item");
    var tabcontentList = document.getElementsByClassName("tab--content__item");
    for(var i = 0; i < toggleBarList.length; i++){
        toggleBarList[i]['data--index'] = i;
        toggleBarList[i].onclick = function(){
            for(var j = 0; j < toggleBarList.length; j++){
                 //toggleBarList[j].className = "tab--toggleBar__item";
                 change(toggleBarList,this['data--index'],['tab--toggleBar__item','tab--toggleBar__item__active']);
                 change(tabcontentList,this["data--index"],['tab--content__item','tab--content__item__show']);
            }
           //this.className = "tab--toggleBar__item tab--toggleBar__item__active";
            //change(this['data--index']);
            console.log(this["data--index"]);
        }
    }
 /*  function change(index){
        for(var i = 0; i < tabcontentList.length; i++){
            tabcontentList[i].className = "tab--content__item";
        }
        tabcontentList[index].className = "tab--content__item tab--content__item__show";
   }*/
    function change(list, index, classArr){
        for(var i = 0; i < list.length; i++){
            list[i].className = classArr[0];
        }
        list[index].className = (classArr + "").replace(",", " ");
    }
</script>
</html>